package cn.jiyun.controller;

import cn.jiyun.common.R;
import cn.jiyun.entity.Dish;
import cn.jiyun.service.DishService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.swing.*;

@RestController
@RequestMapping("/backend")
public class DishController {
    @Resource
    private DishService dishService;
    @GetMapping("page")
    public R<Page> page(int page, int pageSize, Spring name){
        Page page1 = new Page(page,pageSize);
        LambdaQueryWrapper<Dish> queryWrapper = new LambdaQueryWrapper<>();
        if (name!=null){
            queryWrapper.like(Dish::getName,name);
        }
        queryWrapper.orderByAsc(Dish::getUpdateTime);
        dishService.page(page1,queryWrapper);
        return R.success(page1);
    }
}
